// 设计函数 类似习题三 只不过它接受第二个参数指明可以读取的最大字符数
#include <stdio.h>
#define STLEN 20

char * get_word(char *, int len);

int main(void)
{
	char words[STLEN];
	
	puts("输入一行字符:");
	get_word(words, 4);
	printf("--------\n");
	printf("%s\n", words);

	return 0;
}

char * get_word(char * str, int len)
{
	char words[len];
	char *word = words;

	fgets(words, len+1, stdin);
	while(( *word == '\n' || *word == '\t' || *word == ' ') && *word != '\0')
		word++;

	while(*word != '\n' && *word != '\t' && *word != ' ' && *word != '\0')
		*str++ = *word++;

	return 0;
}
